<template>
	<view class="mobile-page" :style="my_style">
		<view class="font-28 p-l-30 p-r-30 p-t-30" style="color: #909090;">为了保证您的账户安全，请验证身份，验证成功进入下一步操作。</view>
		<view class="p-l-30 p-r-30 p-t-30">
			<view class="cell">
				<text class="label">新密码</text>
				<input type="text" v-model="password" placeholder="请输入新密码" />
			</view>
			<view class="cell">
				<text class="label">确认密码</text>
				<input type="text" v-model="re_password" placeholder="请再次输入新密码" />
			</view>
		</view>
		<view class="p-24">
			<view class="primary-btn flex-center m-b-12" @click="resetPassword">确认</view>
		</view>
	</view>
</template>

<script>
	import md5Libs from '@/utils/md5'
	export default {
		data() {
			return {
				password: '',
				re_password: ''
			}
		},
		methods: {
			async resetPassword() {
				if (!this.password || !this.re_password) {
					uni.showToast({
						icon: 'none',
						title: '请输入新密码',
					})
					return
				}

				if (this.password !== this.re_password) {
					uni.showToast({
						icon: 'none',
						title: '两次密码不一致',
					})
					return
				}
				let params = {
					mobile: uni.getStorageSync('login_paw_m'),
					password: md5Libs.md5(md5Libs.md5(uni.$u.trim(this.password)) + 'NiuCloud'),
					re_password: md5Libs.md5(md5Libs.md5(uni.$u.trim(this.password)) + 'NiuCloud'),
					verify_code: '111111'
				}
				const res = await this.$api.common.user('resetPassword', params)
				if (res.code === 200) {
					uni.showToast({
						icon: 'none',
						title: '密码修改成功',
					})
					this.goBack()
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	.mobile-page {
		min-height: 100vh;
		background-color: #fff;
	}

	.cell {
		display: flex;
		height: 100rpx;
		padding: 28rpx 0;
		box-sizing: border-box;
		// background-color: #fff;
		border-bottom: 1px solid #ececec;
		flex-direction: row;
		align-items: center;

		input {
			border-bottom: none;
		}

		.label {
			width: 150rpx;
			display: flex;
			align-items: center;
		}

		.img-code {
			width: 170rpx;
			height: 75rpx;
		}
	}

	.primary-btn {
		width: 100%;
		height: 88rpx;
		font-size: 34rpx;
		color: #fff;
		background: var(--color);
		border-radius: 100rpx;
		margin-top: 130rpx;
	}
</style>
